package com.zff.rental.tools;

/**
 * @author HCY
 */
public class UserContextHolder {
    private static final ThreadLocal<Long> USER_THREAD_LOCAL = new ThreadLocal<>();
    private static final ThreadLocal<String> TOKEN_THREAD_LOCAL = new ThreadLocal<>();

    public static Long getUserId() {
        return USER_THREAD_LOCAL.get();
    }

    public static void setUserId(Long userId) {
        USER_THREAD_LOCAL.set(userId);
    }

    public static String getToken() {
        return TOKEN_THREAD_LOCAL.get();
    }

    public static void setToken(String token) {
        TOKEN_THREAD_LOCAL.set(token);
    }

    public static void clear() {
        USER_THREAD_LOCAL.remove();
        TOKEN_THREAD_LOCAL.remove();
    }
}
